from django.db import models


# Create your models here.


class CateModel(models.Model):
    name = models.CharField(max_length=30, verbose_name='分类名称')

    class Meta:
        db_table = 'cate'

    def __str__(self):
        return self.name


class GoodsModel(models.Model):
    name = models.CharField(max_length=50, verbose_name='商品名称')
    price = models.DecimalField(max_digits=8, decimal_places=2, verbose_name='商品价格')
    cate = models.ForeignKey(CateModel, on_delete=models.CASCADE, verbose_name='商品分类')
    img = models.ImageField(upload_to='static/img', verbose_name='商品图片')

    class Meta:
        db_table = 'goods'

    def __str__(self):
        return self.name
